package org.cloudnote.mapper;

import org.apache.ibatis.annotations.*;
import org.cloudnote.bean.Note;
import org.cloudnote.bean.NoteBook;
import org.cloudnote.bean.Share;

import java.util.List;

public interface NoteMapper {

    @Select("select * from cn_note where cn_notebook_id=#{noteBookId} and cn_note_status_id !='2' ")
    @ResultMap("noteResultMap")
    public List<Note> getByBookId(String noteBookId);

    @Select("select * from cn_note where cn_note_id=#{noteId}")
    @ResultMap("noteResultMap")
    public Note getByNoteId(String noteId);

    @Insert("INSERT INTO cn_note VALUES(#{noteId},#{noteBookId},#{userId},#{noteStatusId},#{noteTypeId},#{noteTittle},#{noteBody},#{noteCreateTime},#{noteLastModifiedTime})")
    public void save(Note note);

    @Update("update cn_note set cn_note_title=#{noteTittle},cn_note_body=#{noteBody} where cn_note_id=#{noteId}")
    public void update(Note note);

    @Update("update cn_note set cn_note_status_id='2' where cn_note_id=#{noteId}")
    public void recycle(String noteId);

    @Update("update cn_note set cn_notebook_id =#{noteBookId} where cn_note_id=#{noteId}")
    public int moveNote(@Param("noteBookId")String noteBookId,@Param("noteId")String noteId);
}
